home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / ead / ead11.dms / ead11.adf / Listati / Sit.c < prev    next >
C/C++ Source or Header  |  1989-01-08  |  5KB  |  182 lines

  1. /***************************************************************
  2. Sit.c - Scritto da Stephen Vermeulen - Fissa il tipo di un'icona
  3.  
  4.          Il formato e': sit nomefile [tipo] [drawer]
  5.  
  6. Il comando lavora sul file "nomefile.info" modificando il tipo
  7. e risalvandolo sotto lo stesso vecchio nome. I tipi sono:
  8.  
  9. 1 --------------> DISK
  10. 2 --------------> DRAWER (Directory)
  11. 3 --------------> TOOL
  12. 4 --------------> PROJECT
  13. 5 --------------> GARBAGE
  14. 6 --------------> DEVICE (CHE COOOOSA ?????????!!!!!!!)
  15. 7 --------------> KICK
  16.  
  17. Traduzione ed adattamento per Aztec C V3.6 di Luigi R. Callegari
  18. Programma di Pubblico Dominio. Non alterare le scritte. FTE Srl
  19. ****************************************************************/
  20.  
  21. #include <intuition/intuition.h>
  22. #include <workbench/workbench.h>
  23. #include <stdio.h>
  24. #include <functions.h>
  25.  
  26. #define NO_ICONS       4
  27.  
  28. extern ULONG IconBase;
  29.  
  30. /************************************************************
  31.  Qui apriamo semplicemente le librerie che ci occorrono
  32. ************************************************************/
  33.  
  34. short OpenLibs()
  35. {
  36.   short flags; /* per memorizzare librerie inapribili */
  37.  
  38.   flags = 0;
  39.   IconBase = (ULONG) OpenLibrary("icon.library", 0L);
  40.   if (!IconBase) flags |= NO_ICONS;
  41.   return(flags);
  42. }
  43.  
  44. void CloseLibs(flags)
  45. short flags;
  46. {
  47.   if (!(flags & NO_ICONS))     CloseLibrary(IconBase);
  48. }
  49.  
  50. void main(argc, argv)
  51. short argc;
  52. char *argv[];
  53. {
  54.   short lib_flags, icon_type;
  55.   struct DiskObject *dobj, *drawer_obj;
  56.   struct DrawerData *dd_temp;
  57.  
  58.   if (argc >= 3)
  59.   {
  60.     lib_flags  = OpenLibs();
  61.     if (!lib_flags)
  62.     {
  63.       if (dobj = GetDiskObject(argv[1]))
  64.       {
  65.         sscanf(argv[2], "%d", &icon_type);
  66.         if (icon_type < 1) icon_type = 1;
  67.         if (icon_type > 7) icon_type = 7;
  68.         if ((icon_type == 1) || (icon_type == 2) || (icon_type == 5))
  69.         {
  70.  
  71. /* Qui si e' richiesto di rendere l'icona di tipo drawer, disk o trashcan,
  72. quindi verifichiamo che l'originale sia proprio di questo tipo */
  73.  
  74.            if ((dobj->do_Type == 1) || (dobj->do_Type == 2) || (dobj->do_Type == 5))
  75.            {
  76.              /** ok a procedere **/
  77.              dobj->do_Type = icon_type;
  78.              PutDiskObject(argv[1], dobj);
  79.            }
  80.            else
  81.            {
  82. /* Dobbiamo leggere dei dati extra da una semplice drawer, disk o 
  83. trashcan per potere modificare il file informativo appropriatamente */
  84.  
  85.              if (argc == 4)
  86.              {
  87.                /** corregge numero di parametri **/
  88.  
  89.                if (drawer_obj = GetDiskObject(argv[3]))
  90.                {
  91.                  if ((drawer_obj->do_Type == 1) ||
  92.                      (drawer_obj->do_Type == 2) ||
  93.                      (drawer_obj->do_Type == 5))
  94.                  {
  95.                    /** se e' il tipo di icona corretta **/
  96.  
  97.                    dd_temp = dobj->do_DrawerData;
  98.                    dobj->do_DrawerData = drawer_obj->do_DrawerData;
  99.                    dobj->do_Type = icon_type;
  100.                    PutDiskObject(argv[1], dobj);
  101.                    dobj->do_DrawerData = dd_temp;
  102.                  }
  103.                  else
  104.                    printf("%s Deve essere DRAWER, DISK, o TRASHCAN\n", argv[3]);
  105.                  FreeDiskObject(drawer_obj);
  106.                }
  107.              }
  108.              else
  109.                printf("Bisogna specificare anche una icona di drawer!\n");
  110.            }
  111.         }
  112.         else
  113.         {
  114.     /* Se l'originale era di tipo DRAWER, eseguiamo il dump */
  115.  
  116.            dd_temp = dobj->do_DrawerData;
  117.            dobj->do_DrawerData = NULL;
  118.            dobj->do_Type = icon_type;
  119.            PutDiskObject(argv[1], dobj);
  120.            dobj->do_DrawerData = dd_temp;
  121.         }
  122.         FreeDiskObject(dobj);
  123.       }
  124.     }
  125.     CloseLibs(lib_flags);
  126.   }
  127.   else if (argc == 2)
  128.   {
  129.     lib_flags  = OpenLibs();
  130.     if (!lib_flags)
  131.     {
  132.       if (dobj = GetDiskObject(argv[1]))
  133.       {
  134.         printf("Tipo %d ", dobj->do_Type);
  135.         switch(dobj->do_Type)
  136.         {
  137.           case 1:
  138.             printf("WBDISK\n");
  139.             break;
  140.           case 2:
  141.             printf("WBDRAWER\n");
  142.             break;
  143.           case 3:
  144.             printf("WBTOOL\n");
  145.             break;
  146.           case 4:
  147.             printf("WBPROJECT\n");
  148.             break;
  149.           case 5:
  150.             printf("WBGARBAGE\n");
  151.             break;
  152.           case 6:
  153.             printf("WBDEVICE\n");
  154.             break;
  155.           case 7:
  156.             printf("WBKICK\n");
  157.             break;
  158.           deafult:
  159.             printf("TIPO SCONOSCIUTO!\n");
  160.         }
  161.         FreeDiskObject(dobj);
  162.       }
  163.     }
  164.     CloseLibs(lib_flags);
  165.   }
  166.   else
  167.   {
  168.     printf("Sintassi: sit icon [newtype] [drawer|disk|trashcan]\n");
  169.     printf("newtype:  1 = disk     2 = drawer   3 = tool\n");
  170.     printf("          4 = project  5 = garbage  6 = device  7 = kick\n");
  171.     printf("Versione 1.10i\n");
  172.     printf("Scritto da:      Stephen Vermeulen\n");
  173.     printf("                 3635 Utah Dr. N.W.,\n");
  174.     printf("                 Calgary, Alberta,\n");
  175.     printf("                 CANADA, T2N 4A6\n");
  176.     printf("\nMandate un contributo libero od un analisi dei bug!\n");
  177.     printf("Software distribuito da EnigmA Amiga Disk\n");
  178.   }
  179. }
  180.  
  181. /******************************* FINE DEL FILE *************************/
  182.